package com.lkl.demo.controller;

import com.lkl.demo.common.result.R;
import com.lkl.demo.vo.LoginVo;
import com.lkl.demo.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 用户表
 *
 * @author likelong
 * @date 2022-07-25
 */
@Controller
@RequestMapping("/user")
@Api(value = "用户表", tags = "用户表")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 跳转登录页面
     */
    @ApiOperation("跳转登录页面")
    @GetMapping("/toLogin")
    public String toLogin() {
        return "login";
    }

    @ApiOperation("登录接口")
    @ResponseBody
    @PostMapping("/doLogin")
    public R doLogin(@Valid LoginVo loginVo) {
        return userService.doLogin(loginVo);
    }
}
